package Game.Online.Messages 
{
	import Box2D.Common.Math.b2Vec2;
	import flash.utils.ByteArray;
	import Game.Online.OnlineManager;
	/**
	 * ...
	 * @author Yevgeniy Logachev
	 */
	public class MessageLogIn extends Message
	{
		public function MessageLogIn(id:String = null)
		{
			if (id == null) 
			{
				id = OnlineManager.instance.connection.id;
			}
			super(MessagesDefs.k_MESSAGE_LOGIN, id);

			setData("", 0, 0, 0);
		}
		
		public function setData(name:String, health:int, posx:Number, posy:Number):void
		{
			m_data.position = MSG_OFFSET_ID;
			m_data.readUTF();
			
			m_data.writeUTF(name);
			m_data.writeInt(health);
			m_data.writeDouble(posx);
			m_data.writeDouble(posy);
		}
		
		public function get name():String
		{
			m_data.position = MSG_OFFSET_ID;
			m_data.readUTF();
			
			return m_data.readUTF();
		}
		
		public function get health():int
		{
			m_data.position = MSG_OFFSET_ID;
			m_data.readUTF();
			m_data.readUTF();
			
			return m_data.readInt();			
		}
		
		public function get posX():Number
		{
			m_data.position = MSG_OFFSET_ID;
			m_data.readUTF();
			m_data.readUTF();
			m_data.readInt();
			
			return m_data.readDouble();
		}
		
		public function get posY():Number
		{
			m_data.position = MSG_OFFSET_ID;
			m_data.readUTF();
			m_data.readUTF();
			m_data.readInt();
			m_data.readDouble();
			
			return m_data.readDouble();
		}
	}
}